﻿using BonjourQuotation.DataAccess.Repositories;
using BonjourQuotation.ObjectModel.BusinessData;
using BonjourQuotation.ObjectModel.ErrorData;
using BonjourQuotation.ObjectModel.LoggerData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BonjourQuotation.UI.ServiceManagers
{
    public class OperationManager
    {
        private readonly log4net.ILog logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        public OperationHotelGridBData LoadOperationHotels(int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationHotels(PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationRoomGridBData LoadOperationRooms(int PageNum, List<string> UserRegions)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationRooms(PageNum, UserRegions);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationAttractionsGridBData LoadOperationAttractions(int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationAttractions(PageNum, UserRegions, UserName);
            } 
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationMiscGridBData LoadOperationMisc(int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationMisc(PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationBusGridBData LoadOperationBus(int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationBus(PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationTechProgGridBData LoadOperationTechProg(string GroupCode, OperationTechProgFilterBData FilterData)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationTechProg(GroupCode, FilterData);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationTechProgGridBData ValidateOperationTechProg(string GroupCode, OperationTechProgFilterBData FilterData)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.ValidateOperationTechProg(GroupCode, FilterData);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationGroupCheckListGridBData LoadOperationGroupCheckList(int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationGroupCheckList(PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationRoomGridBData LoadOperationRooms(int PageNum, OperationRoomSearchBData Data, List<string> UserRegions)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationRooms(PageNum, Data, UserRegions);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationHotelGridBData SearchOperationHotels(OperationHotelGridBData Data, OperationHotelFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationSearchHotel(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationAttractionsGridBData SearchOperationAttractions(OperationAttractionsGridBData Data, OperationAttractionsFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationSearchAttractions(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationAttractionsGridBData OperationAttractionsFilter(OperationAttractionsGridBData Data, OperationAttractionsFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationFilterAttractions(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationAttractionsGridBData OperationAttractionsSave(OperationAttractionsGridBData Data, OperationAttractionsFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationAttractions(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationMiscGridBData SearchOperationMisc(OperationMiscGridBData Data, OperationMiscFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationSearchMisc(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationMiscGridBData OperationMiscFilter(OperationMiscGridBData Data, OperationMiscFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationFilterMisc(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationMiscGridBData OperationMiscSave(OperationMiscGridBData Data, OperationMiscFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationMisc(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationBusGridBData SearchOperationBus(OperationBusGridBData Data, OperationBusFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationSearchBus(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationBusGridBData OperationBusFilter(OperationBusGridBData Data, OperationBusFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationFilterBus(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationBusGridBData OperationBusSave(OperationBusGridBData Data, OperationBusFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationBus(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationGroupCheckListGridBData SearchOperationGroupCheckList(OperationGroupCheckListGridBData Data, OperationGroupCheckListFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationSearchGroupCheckList(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationGroupCheckListGridBData OperationGroupCheckListFilter(OperationGroupCheckListGridBData Data, OperationGroupCheckListFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationFilterGroupCheckList(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationTechProgGridBData OperationTechProgSave(OperationTechProgGridBData Data, OperationTechProgFilterBData FilterData)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationTechProg(Data, FilterData);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationHotelGridBData OperationHotelsFilter(OperationHotelGridBData Data, OperationHotelFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationFilterHotel(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationHotelGridBData OperationHotelSave(OperationHotelGridBData Data, OperationHotelFilterBData FilterData, int PageNum, List<string> UserRegions, string UserName)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationHotel(Data, FilterData, PageNum, UserRegions, UserName);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationRoomGridBData OperationRoomsFilter(OperationRoomFilterBData Data, int PageNum, List<string> UserRegions)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationFilterRoom(Data, PageNum, UserRegions);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationRoomGridBData OperationRoomsRemove(OperationRoomFilterBData Data, int GroupId, int LineNo, int PageNum, List<string> UserRegions)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.RemoveOperationRooms(Data, GroupId, LineNo, PageNum, UserRegions);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationRoomGridBData OperationRoomsSave(OperationRoomGridBData Data, OperationRoomFilterBData FilterData, int PageNum, List<string> UserRegions)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationRooms(Data, FilterData, PageNum, UserRegions);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ErrorBInfo OverWriteOperationRooms(int GroupID)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OverWriteOperationRooms(GroupID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ErrorBInfo OverWriteOperationRoomsByVendorID(int GroupID, int VendorID, DateTime ArrivalDate)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OverWriteOperationRoomsByVendorID(GroupID, VendorID, ArrivalDate);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationGirGroupPricesGridBData OperationLoadGirPrices(int QuotaID, int GroupID)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationLoadGirPrices(QuotaID, GroupID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationGirGroupPricesGridBData OperationSaveGirPrices(OperationGirGroupPricesGridBData Data)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationSaveGirPrices(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public Dictionary<int, string> FindKeywordInEntity(string PropName, string keyword, List<string> UserRegions)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.FindKeywordInEntity(PropName, keyword, UserRegions);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationRoomSearchGridBData OperationRoomSearchComplete(string PropName, string keyword, List<string> UserRegions)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationRoomSearchComplete(PropName, keyword, UserRegions);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationVendorHotelGridBData OperationVendorHotelGridLoad(int GroupID)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationVendorHotelGridLoad(GroupID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationGVendorRoomGridBData OperationGroupVendorGridLoad(int GroupID, int VendorID)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationGroupVendorGridLoad(GroupID, VendorID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationGVendorRoomGridBData OperationGroupVendorGridSave(OperationGVendorRoomGridBData Data)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationGroupVendorRooms(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationGVendorRoomGridBData RemoveOperationGroupVendorRooms(int GroupID, int VendorID, DateTime ArrivalDate, int LineNo)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.RemoveOperationGroupVendorRooms(GroupID, VendorID, ArrivalDate, LineNo);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationAttrBusConfirmGridBData OperationAttrBusConfirmationGridLoad(int GroupID, int VendorID, DateTime ArrivalDate, string VendorType)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationAttrBusConfirmGridLoad(GroupID, VendorID, ArrivalDate, VendorType);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationVendorConfirmGridBData OperationVendorConfirmationGridLoad(int GroupID, int VendorID, DateTime ArrivalDate)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationVendorConfirmGridLoad(GroupID, VendorID, ArrivalDate);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationAttrBusConfirmGridBData SaveOperationAttrBusConfirm(OperationAttrBusConfirmGridBData Data)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationAttrBusConfirm(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }
        }
        public OperationVendorConfirmGridBData SaveOperationVendorConfirm(OperationVendorConfirmGridBData Data)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationVendorConfirm(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ErrorBInfo OperationVendorConfirmUpdateProvide(int GroupID, int VendorID, DateTime ArrivalDate)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationVendorConfirmUpdateProvide(GroupID, VendorID, ArrivalDate);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationInvoiceBData OperationLoadInvoiceByGroupID(int GroupID)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationLoadInvoiceByGroupID(GroupID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationInvoiceBData OperationLoadGirInvoice(int GroupID, int CustomerID)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationLoadGirInvoice(GroupID, CustomerID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationInvoiceBData SaveOperationInvoice(OperationInvoiceBData Data)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationInvoice(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationInvoiceBData OperationRemoveInvoice(int GroupID, int LineNo)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationRemoveInvoice(GroupID, LineNo, false, 0);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationInvoiceBData OperationRemoveInvoice(int GroupID, int LineNo, int CustomerID)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.OperationRemoveInvoice(GroupID, LineNo, true, CustomerID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationAmexVendorBData LoadOperationAmexVendors(int VendorID, int GroupID, int CardID, int LineNo, DateTime ArrivalDate, string OperationTabName, string Category, DateTime? Time)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationAmexVendors(VendorID, GroupID, CardID, LineNo, ArrivalDate, OperationTabName, Category, Time);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public OperationOptionalBData LoadOperationOptional(int VendorID)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.LoadOperationOptional(VendorID);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ErrorBInfo SaveOperationAmexVendorDetailsData(OperationAmexVendorBData Data)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.SaveOperationAmexVendorDetailsData(Data);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public ErrorBInfo UpdateVendorConfirmPath(int VendorID, int GroupID, string VendorConfrimPath, string VendorType, bool UpdateAll)
        {
            try
            {
                var proxy = new OperationRepository();
                return proxy.UpdateVendorConfirmPath(VendorID, GroupID, VendorConfrimPath, VendorType, UpdateAll);
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToMessageAndCompleteStacktrace());
                return null;
            }  
        }
        public bool CheckGroupCodeRegion(string GroupCode, List<string> UserRegions)
        {
            var proxy = new OperationRepository();
            return proxy.CheckGroupCodeRegion(GroupCode, UserRegions);
        }
    }
}